<?php
/**
 * Created by PhpStorm.
 * User: t.young
 * Date: 2018/6/7
 * Time: 11:43
 */

namespace frontend\component;


use common\component\BaseController;
use common\component\Constant;
use common\models\info\Seo;
use yii\helpers\ArrayHelper;

class FrontendBaseController extends BaseController
{
    public $layout = "/main";
    public $allowLog = false;  //前端接口不需要记录日志

    public $except = [];

    public $appEnd = Constant::END_FRONT;

    public $curDomain;

    public $title;
    public $keywords;
    public $description;

    public function runAction($id, $params = [])
    {
        return parent::runAction($id, $params); // TODO: Change the autogenerated stub
    }

    public function beforeAction($action)
    {
        if (!parent::beforeAction($action)) {
            return false;
        }
        $this->curDomain = \Yii::$app->request->getHostInfo();
        //获取url
        $url = \Yii::$app->request->url;
        $data = Seo::getTDK($url,Seo::TDK_PC);
        $this->title = $data['title'];
        $this->keywords = $data['keywords'];
        $this->description = $data['description'];
        return true;
    }

}
